'use strict';
module.exports = {
	/**
	 * 查询分类
	 * @url client/classify/pub/getList 前端调用的url参数地址
	 * data 请求参数
	 * @param {String} type 1文章  2资源
	 */
	main: async (event) => {
		let { data = {}, userInfo, util, filterResponse, originalParam } = event;
		let { customUtil, uniID, config, pubFun, vk, db, _ } = util;
		let { uid } = data;
		let res = { code: 0, msg: "" };
		// 业务逻辑开始-----------------------------------------------------------
		let { type } = data;
		
		let whereJson = {
			status: true
		};
		
		if(vk.pubfn.isNull(type)) {
			return { code: -1, msg: 'type不能为空' };
		} else {
			whereJson["type"] = type;
		}
		
		let dbName = "db-classify";
		
		res["data"] = await vk.baseDao.selects({
			dbName,
			whereJson,
			pageSize: -1,
			getMain: true,
			fieldJson: {
				sort: false,
				trial: false,
				uid: false,
				status: false
			}
		})

		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}
